﻿//-----------------------------------------------------------------------
// <copyright>
// This file is subject to the terms and conditions of the Microsoft Public License (MS-PL).
// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL for more details.
// </copyright>
//----------------------------------------------------------------------- 
using Fulcrum.ControlGenerator;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Fulcrum.UnitTests.ControlGenerator
{
    [TestClass]
    public class TemplatePartDataContextTests
    {
        public TemplatePartDataContextTests()
        {
            // nothing
        }

        [TestMethod]
        public void TestDescription()
        {
            var config = CreateConfig();
            config.Description = "my description";

            var templatePart = new TemplatePartDataContext(config);

            Assert.AreEqual("my description", templatePart.Description);
        }

        [TestMethod]
        public void TestFieldName()
        {
            var config = CreateConfig();

            var templatePart = new TemplatePartDataContext(config);

            Assert.AreEqual("trout", templatePart.FieldName);
        }

        [TestMethod]
        public void TestIsOptional()
        {
            var config = CreateConfig();
            config.Optional = true;

            var templatePart = new TemplatePartDataContext(config);

            Assert.AreEqual(true, templatePart.IsOptional);
        }

        [TestMethod]
        public void TestName()
        {
            var config = CreateConfig();

            var templatePart = new TemplatePartDataContext(config);

            Assert.AreEqual("Trout", templatePart.Name);
        }

        [TestMethod]
        public void TestPartName()
        {
            var config = CreateConfig();

            var templatePart = new TemplatePartDataContext(config);

            Assert.AreEqual("PART_Trout", templatePart.PartName);
        }

        [TestMethod]
        public void TestType()
        {
            var config = CreateConfig();
            config.Type = "Button";

            var templatePart = new TemplatePartDataContext(config);

            Assert.AreEqual("Button", templatePart.Type);
        }

        private static MockTemplatePartConfiguration CreateConfig()
        {
            var config = new MockTemplatePartConfiguration();

            config.Name = "Trout";

            return config;
        }
    }
}
